package com.wyh.copy;

public class Main {
    public static void main(String[] args) throws CloneNotSupportedException {
        School school = new School();
        school.name = "123";
        school.student = new Student();
        school.student.name = "张三";
        school.student.age = 18;

        //引用拷贝
        School school1 = school;
        System.out.println(school1==school);

        //浅拷贝
        School school2 = (School) school.clone();
        System.out.println(school2);
        System.out.println(school2==school);
        System.out.println(school2.student== school.student);

        //深拷贝
        School school3 = (School) school.clone();
        System.out.println(school3);
        System.out.println(school3==school);
        System.out.println(school3.student== school.student);
    }
}
